public class AnimalFactory {
    public Animal createAnimal(String species, String name) {
        switch (species) {
            case "Lion":
                return new Lion(name);
            case "Elephant":
                return new Elephant(name);
            default:
                throw new IllegalArgumentException("Invalid animal species: " + species);
        }
    }
}
